package com.example.simple

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import androidx.lifecycle.lifecycleScope
import com.example.app.base.BaseFragment
import com.example.app.base.BaseSupportFragment
import com.example.app.databinding.AppStateViewEmptyBinding
import com.example.simple.vm.SimpleVM
import com.libhttp.HttpManager

/**
 * 带请求介绍模板
 */
class SimpleReqF : BaseSupportFragment<AppStateViewEmptyBinding>() {
    override fun getLogTag() = "SimpleReqF"
    override fun createViewBinding(inflater: LayoutInflater) = AppStateViewEmptyBinding.inflate(inflater)

    companion object {
        fun startF(fragment: BaseFragment): SimpleReqF {
            val f = SimpleReqF()
            f.arguments = Bundle().apply {

            }
            fragment.start(f)
            return f
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        arguments?.apply {

        }
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        mViewBinding?.apply {

        }
    }


    /**
     * 普通请求结果
     */
    private fun httpResult() {

    }

    /**
     * 普通请求发起
     */
    private fun httpReq() {
        showLoadingDialog()
        SimpleVM.reqTest(viewLifecycleOwner) { code, data, msg ->
            dismissLoadingDialog()
            if (code == HttpManager.CODE_SUCCESS) {

            }
        }

        SimpleVM.mergeReq(lifecycleScope) { aData, bData ->

        }
    }
}